package edu.ptu.acl.common;

import lombok.Data;

@Data
public class ResultVO {

    /**
     * 状态码，比如1000代表响应成功
     */
    private int code;
    /**
     * 响应信息，用来说明响应情况
     */
    private String msg;
    /**
     * 响应的具体数据
     */
    private Object data;

    public ResultVO(MyConstants.ResultCode resultCode, Object data) {
        this.code = resultCode.getCode();
        this.msg = resultCode.getMsg();
        this.data = data;
    }

    public ResultVO(MyConstants.ResultCode resultCode) {
        this.code = resultCode.getCode();
        this.msg = resultCode.getMsg();
    }

    private ResultVO(int code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    private ResultVO(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static ResultVO SuccessMessage(String message){
        ResultVO resultVO = new ResultVO(1000,message);
        return resultVO;
    }

    public static ResultVO falseMessage(String message){
        ResultVO resultVO = new ResultVO(5000,message);
        return resultVO;
    }

    public static ResultVO success(){
        ResultVO resultVO = new ResultVO(MyConstants.ResultCode.SUCCESS);
        return resultVO;
    }

    public static ResultVO success(Object data){
        ResultVO resultVO = new ResultVO(MyConstants.ResultCode.SUCCESS, data);
        return resultVO;
    }

    public static ResultVO fail(){
        ResultVO resultVO = new ResultVO(MyConstants.ResultCode.FAILED);
        return resultVO;
    }

    public static ResultVO fail(Object data){
        ResultVO resultVO = new ResultVO(MyConstants.ResultCode.FAILED,data);
        return resultVO;
    }
    public static ResultVO fail(MyConstants.ResultCode resultCode){
        ResultVO resultVO = new ResultVO(resultCode);
        return resultVO;
    }

}
